package com.ywu.application.standard.role.api;

import com.ywu.common.result.CommonResult;
import com.ywu.application.standard.role.dto.UserRoleDto;
import com.ywu.application.standard.role.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @ClassName RoleApi
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/3/9 16:03
 * @Version 1.0
 **/
@RestController
@RequestMapping("/ywu/role/role")
public class RoleApi {
    @Autowired
    private UserRoleService userRoleService;

    /**
    * @Author GroundDemo
    * @Description 添加角色信息
    * @Date 16:10 2024/3/9
    * @Param [userRoleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/create.role.info")
    public CommonResult<Object> createUserRole(@RequestBody @Valid UserRoleDto userRoleDto) {
        return userRoleService.createUserRole(userRoleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改角色信息
    * @Date 16:26 2024/3/9
    * @Param [userRoleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/update.role.info")
    public CommonResult<Object> updateUserRole(@RequestBody @Valid UserRoleDto userRoleDto) {
        return userRoleService.updateUserRole(userRoleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 删除角色
    * @Date 16:30 2024/3/9
    * @Param [userRoleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/delete.role.info")
    public CommonResult<Object> deleteUserRole(@RequestBody UserRoleDto userRoleDto) {
        return userRoleService.deleteUserRole(userRoleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询角色列表
    * @Date 16:32 2024/3/9
    * @Param [userRoleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/query.role.info")
    public CommonResult<Object> queryUserRole(@RequestBody UserRoleDto userRoleDto) {
        return userRoleService.queryUserRole(userRoleDto);
    }
}
